/* GUI CONVERTED from rcshpsel.p (converter v1.76) Thu Jul  4 11:42:27 2002 */
/* rcshpsel.p - MASTER BILL OF LADING MULTI SELECTION ROUTINE                 */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.          */
/*All rights reserved worldwide.  This is an unpublished work. */
/* $Revision: 1.5 $                                                    */
/* $Revision: 1.5 $       BY: R.Satya Narayan    DATE: 06/25/02     ECO: *P086*   */
/*V8:ConvertMode=Maintenance                                                  */
/******************************************************************************/


{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define variable absid         like abs_id       no-undo.
define variable absid1        like abs_id       no-undo.
define variable absshfr       like abs_shipfrom no-undo.
define variable absshfr1      like abs_shipfrom no-undo.
define variable absshto       like abs_shipto   no-undo.
define variable absshto1      like abs_shipto   no-undo.
define variable absshdt       like abs_shp_date no-undo.
define variable absshdt1      like abs_shp_date no-undo.
define variable abstime         as character format "xx:xx" no-undo.
define variable abstime1        as character format "xx:xx" no-undo.
define variable absardt       like abs_arr_date no-undo.
define variable absardt1      like abs_arr_date no-undo.
define variable absart          as character format "xx:xx" no-undo.
define variable absart1         as character format "xx:xx" no-undo.
define variable first_sw_call   as logical initial true   no-undo.
define variable abs_recno       as recid        no-undo.
define variable i               as integer      no-undo.
define variable if-sel-entered  as logical      no-undo.
define variable msgnbr         as   integer.
define variable dummy-length   as   character format "999:99".
define variable l_title        as character format "x(35)" no-undo.
define variable l_title2       as character format "x(35)" no-undo.

define shared temp-table shipselect no-undo
   field sel_idr        as character format "x(1)"
   field ab_master_id like abs_master_id
   field ab_id        like abs_id
   field ab_shipfrom  like abs_shipfrom
   field ab_shipto    like abs_shipto
   field ab_shp_date  like abs_shp_date
   field ab_shp_time    as character format "99999"
   field ab_arr_date  like abs_arr_date
   field ab_arr_time    as character format "99999" index sel1 sel_idr desc.


l_title = getFrameTitle("SHIPPER_MULTI_SELECTION", 35).
FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
skip(1)
   absid        colon 20 label "Shipper"
   absid1       colon 45 label "To"
   absshfr      colon 20 label "Ship From"
   absshfr1     colon 45 label "To"
   absshto      colon 20 label "Ship-To/Dock"
   absshto1     colon 45 label "To"
   absshdt      colon 20 label "Ship Date"
   absshdt1     colon 45 label "To"
   abstime      colon 20 label "Ship Time"
   abstime1     colon 45 label "To"
   absardt      colon 20 label "Arrive Date"
   absardt1     colon 45 label "To"
   absart       colon 20 label "Arrival Time"
   absart1      colon 45 label "To"
 SKIP(.4)  /*GUI*/
with frame shipper_sel side-labels width 80  NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-shipper_sel-title AS CHARACTER.
 F-shipper_sel-title = l_title.
 RECT-FRAME-LABEL:SCREEN-VALUE in frame shipper_sel = F-shipper_sel-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame shipper_sel =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame shipper_sel + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame shipper_sel =
  FRAME shipper_sel:HEIGHT-PIXELS - RECT-FRAME:Y in frame shipper_sel - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME shipper_sel = FRAME shipper_sel:WIDTH-CHARS - .5. /*GUI*/



setFrameLabels(frame shipper_sel:handle).

l_title2 = getFrameTitle("UNASSIGNED_SHIPPERS", 35).
FORM /*GUI*/  shipselect.sel_idr     column-label "Sel"           format "x(3)"
   shipselect.ab_shipfrom   column-label "Ship From"
   shipselect.ab_id         column-label "Shipper"       format "x(10)"
   shipselect.ab_shipto     column-label "Ship-To/Dock"
   shipselect.ab_shp_date   column-label "Ship Date"
   shipselect.ab_shp_time   column-label "Ship Time"
   shipselect.ab_arr_date   column-label "Arr Date"      format "99/99/99"
   shipselect.ab_arr_time   column-label "Arr Time"      format "99999"
with frame cd down width 80 title l_title2 THREE-D /*GUI*/.


setFrameLabels(frame cd:handle).

for first co_ctrl no-lock:
end.
for first gl_ctrl no-lock:
end.


for each shipselect exclusive-lock:
   delete shipselect.
end.

select_block:
do:

   do on error undo, retry on endkey undo, leave select_block:
/*GUI*/ if global-beam-me-up then undo, leave.



      if absid1   = hi_char  then absid1   = "".
      if absshfr1 = hi_char  then absshfr1 = "".
      if absshto1 = hi_char  then absshto1 = "".
      if absshdt1 = hi_date  then absshdt1 = ?.
      if absardt1 = hi_date  then absardt1 = ?.
      if absardt  = low_date then absardt  = ?.
      if absshdt  = low_date then absshdt  = ?.
      if abstime1 = "9999" then abstime1 = "".
      if absart1  = "9999" then absart1  = "".

      set absid
         absid1
         absshfr
         absshfr1
         absshto
         absshto1
         absshdt
         absshdt1
         abstime
         abstime1
         absardt
         absardt1
         absart
         absart1
      with frame shipper_sel.


      /* EDIT USER INPUT TIME FIELDS */
      {gprun.i ""fstimchk.p""
         "(input         ""T"",
           input         abstime,
           input         """",
           output        abstime,
           output        dummy-length,
           output        msgnbr)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      /* FSTIMCHK WILL RETURN ONE OF TWO POTENTIAL  */
      /* ERRORS.  #30 IS FOR MINUTES > 59.  #69     */
      /* INDICATES NON-NUMERIC INPUT, IN WHICH CASE */
      /* WE WANT TO PRESERVE AND REDISPLAY THE USER */
      /* INPUT.                                     */

      if msgnbr <> 0 then do:
         {pxmsg.i &MSGNUM=msgnbr &ERRORLEVEL=3}
         next-prompt abstime with frame shipper_sel.
         undo,retry.
      end.

      /* EDIT USER INPUT TIME FIELDS */
      {gprun.i ""fstimchk.p""
         "(input         ""T"",
           input         abstime1,
           input         """",
           output        abstime1,
           output        dummy-length,
           output        msgnbr)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      /* FSTIMCHK WILL RETURN ONE OF TWO POTENTIAL  */
      /* ERRORS.  #30 IS FOR MINUTES > 59.  #69     */
      /* INDICATES NON-NUMERIC INPUT, IN WHICH CASE */
      /* WE WANT TO PRESERVE AND REDISPLAY THE USER */
      /* INPUT.                                     */

      if msgnbr <> 0 then do:
         {pxmsg.i &MSGNUM=msgnbr &ERRORLEVEL=3}
         next-prompt abstime1 with frame shipper_sel.
         undo,retry.
      end.

      /* EDIT USER INPUT TIME FIELDS */
      {gprun.i ""fstimchk.p""
         "(input         ""T"",
           input         absart,
           input         """",
           output        absart,
           output        dummy-length,
           output        msgnbr)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      /* FSTIMCHK WILL RETURN ONE OF TWO POTENTIAL  */
      /* ERRORS.  #30 IS FOR MINUTES > 59.  #69     */
      /* INDICATES NON-NUMERIC INPUT, IN WHICH CASE */
      /* WE WANT TO PRESERVE AND REDISPLAY THE USER */
      /* INPUT.                                     */

      if msgnbr <> 0 then do:
         {pxmsg.i &MSGNUM=msgnbr &ERRORLEVEL=3}
         next-prompt absart with frame shipper_sel.
         undo,retry.
      end.

      /* EDIT USER INPUT TIME FIELDS */
      {gprun.i ""fstimchk.p""
         "(input         ""T"",
           input         absart1,
           input         """",
           output        absart1,
           output        dummy-length,
           output        msgnbr)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      /* FSTIMCHK WILL RETURN ONE OF TWO POTENTIAL  */
      /* ERRORS.  #30 IS FOR MINUTES > 59.  #69     */
      /* INDICATES NON-NUMERIC INPUT, IN WHICH CASE */
      /* WE WANT TO PRESERVE AND REDISPLAY THE USER */
      /* INPUT.                                     */

      if msgnbr <> 0 then do:
         {pxmsg.i &MSGNUM=msgnbr &ERRORLEVEL=3}
         next-prompt absart1 with frame shipper_sel.
         undo,retry.
      end.
      if absid1   = "" then absid1   = hi_char.
      if absshfr1 = "" then absshfr1 = hi_char.
      if absshto1 = "" then absshto1 = hi_char.
      if absshdt1 = ?  then absshdt1 = hi_date.
      if absardt1 = ?  then absardt1 = hi_date.
      if absardt  = ?  then absardt  = low_date.
      if absshdt  = ?  then absshdt  = low_date.
      if abstime1 = "" then abstime1 = "9999".
      if absart1  = "" then absart1  = "9999".
   end.
/*GUI*/ if global-beam-me-up then undo, leave.

   assign
      abstime  = string(abstime,"xx:xx")
      abstime1 = string(abstime1,"xx:xx")
      absart   = string(absart,"99:99")
      absart1  = string(absart1,"99:99").

   if abstime1 = "00:00" then abstime1 = "99:99".
   if absart1  = "00:00" then absart1  = "99:99".

   workloop:
   for each abs_mstr  where abs_type = "s"
                       and trim(substring(abs_mstr.abs_status,2,1)) = "y"
                       and abs_mstr.abs_master_id = "" no-lock:
      create shipselect.
      assign
         shipselect.ab_master_id = abs_mstr.abs_master_id
         shipselect.ab_id        = trim(substring(abs_mstr.abs_id,2))
         shipselect.ab_shipfrom  = abs_shipfrom
         shipselect.ab_shipto    = abs_shipto
         shipselect.ab_shp_date  = abs_shp_date
         shipselect.ab_shp_time  = string(abs_shp_time,"hh:mm")
         shipselect.ab_arr_date  = abs_arr_date
         shipselect.ab_arr_time  = string(abs_arr_time, "hh:mm").

      do i = 1 to 5:
         if trim(substring(shipselect.ab_shp_time,i,1)) = "" then
            trim(substring(shipselect.ab_shp_time,i,1)) = "0".
         if trim(substring(shipselect.ab_arr_time,i,1)) = "" then
            trim(substring(shipselect.ab_arr_time,i,1)) = "0".
      end.
   end.


   find first shipselect no-lock no-error.
   if not available shipselect then leave.

   if-sel-entered = yes.
   if absid    = ""
      and absid1   = hi_char
      and absshfr  = ""
      and absshfr1 = hi_char
      and absshto  = ""
      and absshto1 = hi_char
      and absshdt  = low_date
      and absshdt1 = hi_date
      and (abstime  = "" or abstime  = "00:00")
      and (abstime1 = "99:99" or abstime1 = "00:00")
      and absardt  = low_date
      and absardt1 = hi_date
      and (absart   = ""  or  absart  = "00:00")
      and (absart1  = "99:99" or absart1  = "00:00") then
      if-sel-entered = no.



   if if-sel-entered = yes then
   for each shipselect use-index sel where shipselect.ab_id >=  absid
      and shipselect.ab_id         <=  absid1
      and shipselect.ab_shipfrom   >= absshfr
      and shipselect.ab_shipfrom   <= absshfr1
      and shipselect.ab_shipto     >= absshto
      and shipselect.ab_shipto     <= absshto1
      and (
             (shipselect.ab_shp_date >= absshdt
              and shipselect.ab_shp_date <= absshdt1
             )
             or (shipselect.ab_shp_date   = ?
                 and absshdt1 = hi_date
                )
          )
      and shipselect.ab_shp_time   >= abstime
      and shipselect.ab_shp_time   <= abstime1
      and (
            (shipselect.ab_arr_date >= absardt
             and shipselect.ab_arr_date <= absardt1
            )
            or (shipselect.ab_arr_date   = ?
                and absardt1 = hi_date
               )
          )
      and shipselect.ab_arr_time   >= absart
      and shipselect.ab_arr_time   <= absart1
      and shipselect.ab_master_id  = ""  exclusive-lock:

      assign shipselect.sel_idr = "*".
   end.

   hide frame shipper_sel no-pause.
   sw_block:
   do on error undo,retry on endkey undo,leave select_block :
/*GUI*/ if global-beam-me-up then undo, leave.

      if not batchrun then do:
         view frame cd.
         find first shipselect no-lock no-error.

         {swselect.i
            &detfile      = shipselect
            &scroll-field = shipselect.ab_id
            &framename    = "cd"
            &framesize    = 12
            &sel_on       = ""*""
            &sel_off      = """"
            &display1     = shipselect.sel_idr
            &display2     = shipselect.ab_shipfrom
            &display3     = shipselect.ab_id
            &display4     = shipselect.ab_shipto
            &display5     = shipselect.ab_shp_date
            &display6     = shipselect.ab_shp_time
            &display7     = shipselect.ab_arr_date
            &display8     = shipselect.ab_arr_time
            &exitlabel    = sw_block
            &exit-flag    = first_sw_call
            &record-id    = abs_recno
         }
         if keyfunction(lastkey) = "end-error"
            or lastkey = keycode("F4")
            or lastkey = keycode("CTRL-E")
            or lastkey = keycode("ESC") then do:
            for each shipselect exclusive-lock:
               delete shipselect.
            end.
            undo,leave.
         end.
      end.
   end.
/*GUI*/ if global-beam-me-up then undo, leave.

end.
hide frame shipper_sel no-pause.
hide frame cd no-pause.
